<?php
/**
 * Author:   tangxiaowen
 * Email:    846506584@qq.com
 * Date:     2019/5/24 0024
 * Describe: 协议管理类.
 */

namespace app\api\controller\lishidai;

use think\Controller;

class Agreement extends Controller
{
    /**
     * 借款协议.
     */
    public function loan()
    {
        $orderSn = input('orderSn');
        //获取系统配置信息及协议内容
        $systemName = model('System')->getSystemInfo();
        //获取协议内容数据并替换内容数据
        $agreementData = db('sys_content_change')->where(['Title' => '借款协议'])->value('Contents');

        //获取用户信息
        $userOrderData = db('loans_applylist')->alias('a')
            ->join('xb_mem_info i', 'a.UserID = i.ID')
            ->where(['OrderSn' => $orderSn])
            ->find();
        $arr1 = ['甲方名称',            '甲方身份证',         '签订日期'];
        $arr2 = [$userOrderData['TrueName'], $userOrderData['IDCard'], date('Y年m月d日')];
        array_push($arr1, '订单编号', '乙方名称', '乙方身份证', '丙方名称', '丁方名称', '1000.00', '2018年12月19日', '2018年12月25日', '36%', '[7]天', '借款还款日', '1007.00');
        array_push($arr2, $userOrderData['OrderSn'], $systemName['yifang'], $systemName['shenfenzheng'], $systemName['bingfang'], $systemName['dingfang'], $userOrderData['AdoptMoney'], $userOrderData['OpenTime'], $userOrderData['YyFkTime'], $userOrderData['nianhualilv'].'%', '['.$userOrderData['ApplyDay'].']天', $userOrderData['YyFkTime'], $userOrderData['ApplyMoney']);
        $str = str_replace($arr1, $arr2, $agreementData);
        $this->assign('str', $str);

        return view();
    }

    /**
     * 代扣协议.
     */
    public function withhold()
    {
        //获取系统配置信息及协议内容
        $systemName = model('System')->getSystemInfo();
        //获取协议内容数据并替换内容数据
        $agreementData = db('sys_content_change')->where(['Title' => '代扣协议'])->value('Contents');
        $str = str_replace('某网络信息科技有限公司', $systemName['SystemName'], $agreementData);

        $this->assign('str', $str);

        return view();
    }
}
